var nodemailer = require('nodemailer');

function sendMial(server,sender,sendpass,reciever,sub,text){
  var transporter = nodemailer.createTransport("smtps://"+sender+":"+sendpass+"@smtp."+server+".com");
  var from = sender.split('@')[0];
  var mailOptions = {
    from: from+" <"+sender+">", // sender address
    to: reciever, // list of receivers
    subject: sub, // Subject line
    text: text, // plaintext body
  };

  transporter.sendMail(mailOptions, function(error, info){
    if(error){
      console.log('mailerror');
      console.log(error);
    }else{
      console.log('Message sent: ' + info.response);
    }
  });
}

module.exports = sendMial;